/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */
/**
 * @param {ListNode} head
 * @param {number} val
 * @return {ListNode}
 */
 var deleteNode = function(head, val) {
    let node=head;
    let newhead=head;
    if(head.val==val){
        return head.next;
    }
    head=head.next;
    while(head!=null){
        if(head.val==val){
            node.next=head.next;
            return newhead;
        }
        node = head;
        head = head.next;
    }
};